<template>
  <div id="app">
    <myHeader></myHeader>
    <!-- 指定组件的呈现位置 -->
    <router-view ></router-view  >
    <!-- 在Home、Search显示的，在Login.register是隐藏的 -->
    <!-- <myFooter></myFooter> -->
    <myBanner v-show="$route.meta.show"></myBanner>
    <!-- <myFooter v-show="$route.meta.show"></myFooter> -->
  </div>
</template>

<script>

// 引入首页组件
import myHeader from './components/myHeader.vue';
import myFooter from './components/myFooter.vue';
import myBanner from './components/myBanner.vue'

export default {
  name: 'App',
  
  components: {
    myHeader,
    myFooter,
    myBanner
  },
  methods:{
  //   _isMobile() {
	//  let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
	//  return flag;
  // },
},
mounted(){
     // 向actions派发请求
    this.$store.dispatch('getAllBlog')
    // 向action派发请求
    this.$store.dispatch('getAllImg')
    // if (this._isMobile()) {
    //   window.location = 'http://1.12.58.122:3435'; 
    // } else {
    // }
    // if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
    //   window.location.href = "http://m.baidu.com/"; //手机
    // } else {
    //   window.location.href = "https://www.baidu.com/"; //电脑
    // }
    
    this.$bus.$on("changePic", (data) => {
      let body = document.querySelector('body')
      body.style.backgroundImage = `url(/images/${data})`
    });
}
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 0px;
  position: relative;
  
}
html,body,#app{
 		height: 100%;
 		width: 100%;
    font-size:0;
	}
 
</style>
